package fr.pascal.client.activity;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

import fr.pascal.client.ClientFactory;
import fr.pascal.client.place.ChatPlace;
import fr.pascal.client.place.KangourouPlace;
import fr.pascal.client.ui.animal.ChatView;

public class ChatActivity extends AbstractActivity implements ChatView.Presenter {

	private ClientFactory clientFactory;
	private ChatPlace chatPlace;

	public ChatActivity(ClientFactory clientFactory, ChatPlace chatPlace) {
		this.clientFactory = clientFactory;
		this.chatPlace = chatPlace;
	}

	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		ChatView chatView = clientFactory.getChatView();
		chatView.setNomChat(chatPlace.getToken());
		chatView.setPresenter(this);
		panel.setWidget(chatView.asWidget());
	}

	@Override
	public void goTo(KangourouPlace kangourouPlace) {
		clientFactory.getPlaceController().goTo(kangourouPlace);
	}
}
